package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;
import com.songlanyun.common.utils.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

/**
 * 维权订单的相关枚举
 */
public class RightsOrderConstant {


    /**
     * 维权的货物状态 （0未收货，1已收货）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum RightsCargoStatus implements IntegerEnum<Integer> {
        NOT(0, "未收货"),
        YES(1, "已收货");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        RightsCargoStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static RightsCargoStatus getByCode(int code) {
            for (RightsCargoStatus value : RightsCargoStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 维权退款状态（0待退款，1退款成功，2退款失败）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum RightsRefundStatus implements IntegerEnum<Integer> {
        WAIT(0, "待退款"),
        SUCCESS(1, "退款成功"),
        FAIL(2, "退款失败");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        RightsRefundStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static RightsRefundStatus getByCode(int code) {
            for (RightsRefundStatus value : RightsRefundStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 维权订单操作状态（0申请，1同意，2买家已发货，3商家已收到退货商品,4商家发起退款支付，5已支付退款,6拒绝，7自动关闭,8主动撤消
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum RightsOperateStatus implements IntegerEnum<Integer> {
        APPLY(0, "申请"),
        AGREE(1, "商家同意"),
        USER_SHIP(2, "买家已发货"),
        SHOP_RECEIPT(3, "商家已收到退货商品"),
        SEND_REFUND(4, "商家发起退款支付"),
        REFUND_COMPLETE(5, "已支付退款"),
        REFUSE(6, "商家拒绝"),
        AUTO_CLOSE(7, "自动关闭"),
        CANCEL(8, "主动撤消"),
        ;
        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        RightsOperateStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static RightsOperateStatus getByCode(int code) {
            for (RightsOperateStatus value : RightsOperateStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }



    /**
     * 操作人（0会员，1系统,2商家）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum RightsOperatePerson implements IntegerEnum<Integer> {
        USER(0, "会员"),
        SYSTEM(1, "系统"),
        SHOP(2, "商家"),

        ;
        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        RightsOperatePerson(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static RightsOperatePerson getByCode(int code) {
            for (RightsOperatePerson value : RightsOperatePerson.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

}
